//
//  BaseTextField.swift
//  Lottery
//
//  Created by 黄丹 on 2019/1/14.
//  Copyright © 2019 薛永伟. All rights reserved.
//

import UIKit

/// 自定义placeholder的TextFiled
class YRPlaceholderTextField: UITextField {
    
    @IBInspectable var placeholderFontSize:CGFloat = 14
    @IBInspectable var placeholderFontColor:UIColor = UIColor.init(rgb: 0xDADADA)!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        customSubviews()
    }
    
    override var placeholder: String?{
        didSet{
            if let str = placeholder {
                
                self.attributedPlaceholder = NSAttributedString.init(string: str,
                                                                     attributes:
                    [
                        NSAttributedString.Key.font:UIFont.systemFont(ofSize: placeholderFontSize.scaleLength),
                        NSAttributedString.Key.foregroundColor:placeholderFontColor
                    ])
            }else{
                self.attributedPlaceholder = nil
            }
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        customSubviews()
        if let holder = self.placeholder {
            self.placeholder = holder
        }
    }
    
    func customSubviews(){
        
    }
    
}
